<%--
  Created by IntelliJ IDEA.
  User: LikZ
  Date: 2021.8.31
  Time: 下午 17:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>user_list</title>
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet" />
    <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
</head>
<body>

    <table class="table table-bordered table-hover table-striped">
        <tr>
            <th>
                <input type="checkbox" id="countCheckBox" />
            </th>
            <th>用户uid</th>
            <th>用户名昵称</th>
            <th>密码</th>
            <th>真实姓名</th>
            <th>邮箱</th>
            <th>出生日期</th>
            <th>性别</th>
            <th>激活状态</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${pd.list}" var="u" varStatus="status">
            <tr>
                <td>
                    <input type="checkbox"  name="item" />
                </td>
                <td>${u.uid}</td>
                <td>${u.username}</td>
                <td>${u.password}</td>
                <td>${u.name}</td>
                <td>${u.email}</td>
                <td>${u.birthday}</td>
                <td>${u.sex}</td>
                <td>${u.state}</td>
                <td>
                    <a href="${pageContext.request.contextPath}/admindeleteuser?uid=${u.uid}" class="btn btn-danger">删除</a>
                    <a href="${pageContext.request.contextPath}/finduser?uid=${u.uid}" class="btn btn-primary">修改</a>
                </td>
            </tr>
        </c:forEach>
    </table>



<a href="#" class=" btn btn-danger" style="float: right;margin-right: 20px">全部删除</a>

<div style="margin-left: 600px">
    <%--分页组件--%>
    <nav aria-label="Page navigation">
        <ul class="pagination">
            <%--上一页--%>
            <%--
                判断是否是第一页
            --%>
            <c:if test="${pd.currentPage==1}">
                <li class="disabled">
                    <a href="javascript:void(0)" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
            </c:if>
                <%--如果不是第一页 --%>
            <c:if test="${pd.currentPage!=1}">
                <li>
                    <a href="${pageContext.request.contextPath}/findUserByPage?currentPage=${pd.currentPage-1}&pageSize=4" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
            </c:if>


             <c:forEach begin="1" end="${pd.totalPage}" var="n">

                 <c:if test="${pd.currentPage==n}">
                     <li class="active"><a href="javascript:void(0)">${n}</a></li>
                 </c:if>
                 <c:if test="${pd.currentPage!=n}">
                     <li><a href="${pageContext.request.contextPath}/findUserByPage?currentPage=${n}&pageSize=4">${n}</a></li>
                 </c:if>

             </c:forEach>

            <%--下一页--%>
                <%--判断是否使最后一页--%>
                <c:if test="${pd.currentPage==pd.totalPage}">
                    <li class="disabled">
                        <a href="javascript:void(0)" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </c:if>
            <c:if test="${pd.currentPage!=pd.totalPage}">
                <li>
                    <a href="${pageContext.request.contextPath}//findUserByPage?currentPage=${pd.currentPage+1}&pageSize=4" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            </c:if>

        </ul>
    </nav>
</div>
<span style="float: right;margin-right: 40px">
    共有:${pd.totalPage}页 总记录数:${pd.totalCount}条 每页显示${pd.pageSize}条
</span>
</body>
<script>
    window.onload = function () {
        document.getElementById("countCheckBox").onclick=function () {
            var chb =document.getElementsByName("item");
            for(var x = 0; x<chb.length;x++){
                chb[x].checked = this.checked;
            }
        }
    }
</script>
</html>
